// 小程序分享
document.write('<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>');
document.write('<script type="text/javascript" src="/js/wxShare.js" defer></script>');
document.write('<script type="text/javascript" src="/js/interest.js?v=4.1"></script>');
document.write('<script type="text/javascript" src="https://culturecloud.oss-cn-hangzhou.aliyuncs.com/app/js/ct_app_api_v2.0.0.js?v=4"></script>');
document.write('<script type="text/javascript" src="/js/aes.js"></script>');
// document.write('<script type="text/javascript" src="/js/vconsole.min.js"></script>');

const hostName = window.location.hostname;
if (hostName.indexOf('m.qzculture.cn') > -1) {
    document.domain = document.domain.split('.').slice(-2).join('.');
}

//APP分享文案
var appShareTitle = '';
var appShareDesc = '';
var appShareImgUrl = '';
var appShareLink = '';
var appAddIntegral = 0;
var userId = '';
var isWifi = true;
let _path = whyConfig.shopPath
if (whyConfig.ssType == 3) {
    _path = whyConfig.shopProvince + '_' + whyConfig.shopPath
}


var ua = navigator.userAgent.toLowerCase();

// 获取tit
function getTit() {
    var url = window.location.pathname + window.location.search;
    if (sessionStorage.getItem(url)) {
        document.title = sessionStorage.getItem(url)
    }
    /*for(i = 0; i < urlObj.length; i++){
        if ( (window.location.href).indexOf(urlObj[i].url) >= 0) {
            document.title = urlObj[i].tit;
        }
    }*/

}

//APP端城市切换
function why_getInjsVariable() {
    if (window.injs) {
        return window.injs;
    } else if (window.parent.injs) {
        return window.parent.injs;
    } else {
        return null;
    }
}

function changeAppBackButtonStyle(num, cityName) {
    var injs = why_getInjsVariable();
    if (injs && typeof injs.changeAppBackButtonStyleWithStyle == 'function') {
        injs.changeAppBackButtonStyleWithStyle(num, cityName);
    }
}

//app获取用户Id
function getAppUserId() {
    if (/wenhuayun/.test(ua)) { //APP端
        if (/android/.test(ua)) { //安卓
            if (window.injs) { //判断是否存在方法
                if (injs.appsdk_UserIsLogin()) {
                    userId = JSON.parse(injs.appsdk_getUserInfo()).userId.length > 0 ? JSON.parse(injs.appsdk_getUserInfo()).userId : JSON.parse(injs.appsdk_getUserInfo()).userId;
                } else {
                    userId = '';
                }
            }
        } else { //ios
            if (window.injs) { //判断是否存在方法
                if (injs.userIsLogin()) {
                    userId = JSON.parse(injs.getUserInfo()).userId;
                } else {
                    userId = '';
                }
            } else {
                if (typeof appsdk_UserIsLogin === 'function') { //存在且是function
                    if (appsdk_UserIsLogin()) {
                        userId = JSON.parse(appsdk_getUserInfo()).userId.length > 0 ? JSON.parse(appsdk_getUserInfo()).userId : JSON.parse(appsdk_getUserInfo()).userId;
                    } else {
                        userId = '';
                    }
                }
            }
        }
    }
}

//设置H5title或APPtitle
function setTitle() {

    if (!$(document).attr("title")) {
        $(document).attr("title", whyConfig.shopTitle);
    } else {
        if (/wenhuayun/.test(ua)) { //APP端
            if (window.injs) { //判断是否存在方法
                injs.changeNavTitle(decodeURIComponent($(document).attr("title")));
            }
        }
    }
}

//H5判断登录状态(未登录跳转登录)
function publicLogin(url) {
    url = url || location.href;

    if (sessionStorage.getItem("isQRCode")) {
        if (url.indexOf('?') != -1) {
            url += '&isQRCode=' + sessionStorage.getItem("isQRCode")
        } else {
            url += '?isQRCode=' + sessionStorage.getItem("isQRCode")
        }
    }

    //再次获取id，以免APP返回不刷新页面
    getAppUserId();

    if (!userId) {
        var ua = navigator.userAgent.toLowerCase();
        if (/wenhuayun/.test(ua)) { //APP端
            if (!window.injs) { //判断是否存在方法
                dialogAlert('系统提示', '登录之后才能操作！');
                return;
            } else {
                injs.accessAppPage(10); //app跳转登录
                return;
            }
        } else { //H5
            if (!/http/.test(url)) {
                url = location.origin + url;
            }
            url = util.encodeUrl(url);
            url = location.origin + '/' + _path + '/setSession.html?url=' + url;
            url = util.encodeUrl(url);

            const _chinaUrl = whyConfig.chinaUrl.split('://')[1];
            whyConfig.chinaUrl = window.location.protocol + '//' + _chinaUrl;
            // 1 群艺馆 2 云站 3 5.0
            const _obj = {
                1: whyConfig.ssQygLogin,
                2: whyConfig.chinaUrl,
                3: whyConfig.ssFiveLogin,
            }
            return window.location.href = _obj[whyConfig.ssType] + '/muser/login.do?type=' + url;

        }

    }
}

//弹出框（自动消失）
function dialogAlert(title, content, time = 1500) {
    $(".ui-popup").remove(); //强制清除弹窗，防止多弹窗不关闭
    if (top.dialog) {
        dialog = top.dialog;
    }
    var d = dialog({
        width: 500,
        title: title,
        content: content,
        fixed: true
    });
    d.show();
    setTimeout(function () {
        d.removeSlow();
    }, time);
}

//弹出框（带事件）
function dialogConfirm(title, content, fn, confirm = '确定') {
    var winW = Math.min(parseInt($(window).width() * 0.82), 575);
    var d = dialog({
        width: winW,
        title: title,
        content: content,
        fixed: true,
        button: [{
            value: confirm,
            callback: function () {
                if (fn) fn();
            },
            autofocus: true
        }]
    });
    d.showModal();
}

//弹出框，双按钮
function dialogConfirmCancel(title, content, fn, confirm = '确定', canle = '取消', bool = false) {
    var winW = Math.min(parseInt($(window).width() * 0.82), 575);
    var d = dialog({
        width: winW,
        title: title,
        content: content,
        fixed: true,
        button: [{
            value: confirm,
            callback: function () {
                if (confirm != '取消' && !bool) {
                    if (fn) fn();
                }

            },
            autofocus: false
        }, {
            value: canle,
            callback: function () {
                if (canle != '取消' && !bool) {
                    if (fn) fn();
                }
            },
        }]
    });
    d.showModal();
}
// layer 弹框
function layerAlert(title, body, cb, shade = '') {
    var _shade = shade === 'isBack' ? 1 : 0.7
    var content = '<div class="tishiContent"> <div class="wenzi">' + body + '</div></div>';
    layer.open({
        type: 1,
        title: [title],
        area: ['600px', 'auto'],
        shade: _shade,
        shadeClose: false,
        btn: ['确定'],
        btnAlign: 'c',
        resize: false,
        skin: 'layui-layer-tishi',
        content: content,
        success: function (layero, index) {
            //console.log('弹窗生成成功');
        },
        yes: function (index, layero) {
            //console.log('点击了第一个按钮');
            if (cb) cb();
            if (_shade === 0.7) {
                layer.close(index);
            }
        },
        btn2: function (index, layero) {
            //console.log('点击了第二个按钮');
            layer.close(index);

        }
    });
}

function layerConfirm(title, body, cb, canle = '取消', confirm = '确定',) {
    var content = '<div class="tishiContent"> <div class="wenzi">' + body + '</div></div>';
    layer.open({
        type: 1,
        title: [title, 'font-size: 26px;padding: 20px 20px 0;color: #000000;'],
        area: ['600', '900'],
        // offset:['100px', '50px'],
        shade: 0.1,
        shadeClose: true,
        btn: [confirm, canle],
        btnAlign: 'c',
        resize: false,
        skin: 'layui-layer-tishi',
        content: content,
        success: function (layero, index) {
            //console.log('弹窗生成成功');
        },
        yes: function (index, layero) {
            // console.log('点击了第一个按钮');
            layer.close(index);
            if (cb) cb();
        },
        btn2: function (index, layero) {
            // console.log('点击了第二个按钮');
            layer.close(index);

        }
    });
}

/**
 * 是否为空对象
 * @param  {object} obj
 * @return {boolean} {}=true,{a:1}=false
 */
var isNullObj = function (obj) {
    if (!obj) return true;
    if (!isPlainObject(obj)) throw new Error('this obj is not PlainObject');
    if (Object.keys(obj).length == 0) return true;
    return false;
}

// 时间格式化
Date.prototype.Format = function (fmt) {
    /*
        注意：ios只支持new Date("2017/2/22 06:23 ")和new Date("2017","2","22","06","23")
        不支持new Date("2017-2-22 06:23 ")和new Date("2017.2.22 06:23 ")
    */
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};

//获取店铺名字并加入shopTitle
function getShopTitle() {
    $.ajax({
        type: "post",
        dataType: "json",
        async: false,
        url: "/" + whyConfig.shopPath + "/modelType",
        success: function (data) {
            whyConfig.shopTitle = data.shopName;
        }
    });
}

//获取数据
function getData(shopPath, areaCode, modelCode, func) {
    var getDataJson = {
        shopPath: shopPath,
        areaCode: areaCode,
        modelCode: modelCode
    };
    $.ajax({
        type: "post",
        dataType: "json",
        data: getDataJson,
        url: "/" + whyConfig.shopPath + "/getShopUserAreaDetail",
        success: function (data) {
            if (data[0].areaIsShown == 1) {
                func(data[0].contentList);
            }
        },
    });
}

//获取url中的参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg); //匹配目标参数
    if (r != null) return decodeURI(r[2]);
    return null; //返回参数值
}

// 图片压缩
function imgCompress(src, size) {
    var _size = size ? size : '_750_500'
    var _ailiSize = _size.split('_');
    if (src)
        return src.indexOf("aliyuncs.com") == -1 ? getIndexImgUrl(src, _size) : (src + "?x-oss-process=image/resize,w_" + _ailiSize[1]);
}


function getIndexImgUrl(imgUrl, size) {
    var pos = imgUrl.lastIndexOf(".");
    var imgUrlIndex = imgUrl.substr(0, pos) + size + imgUrl.substr(pos);
    return imgUrlIndex;
}

// 图片压缩方法 全局通用 适用于jq页面
/**
 * 
 * @param {*} src 图片地址
 * @param {*} size 限制图片大小
 * @returns 
 */
function imgResize(src, size) {
    if (!src) return '';
    var _size = (size && size.indexOf('_750_500') == -1) ? size : '_750_500'
    var _ailiSize = _size.split('_');
    if (src.indexOf('aliyuncs.com') != -1) {
        return src + "?x-oss-process=image/resize,w_" + _ailiSize[1]
    } else if (src.indexOf('wenhuayun') != -1) {
        return getIndexImgUrl(src, _size)
    } else {
        return src;
    }
}

// 图片压缩方法 全局通用 适用于vue页面
/**
 * 
 * @param {*} src 图片地址
 * @param {*} size 限制图片大小
 * @returns 
 */

Vue.prototype.imgResize = function (src, size) {
    if (!src) return '';
    var _size = size ? size : '_750_500'
    var _ailiSize = _size.split('_');
    if (src.indexOf('aliyuncs.com') != -1) {
        return src + "?x-oss-process=image/resize,w_" + _ailiSize[1]
    } else if (src.indexOf('wenhuayun') != -1) {
        return getIndexImgUrl(src, _size)
    } else {
        return src;
    }
}
//底部菜单
function footerMenu(data) {
    for (var i = 0; i < data.length; i++) {

        $("#area_T").append(
            '<div class="footerWc area_T' + i + '">' +
            '<ul class="footer clearfix"></ul>' +
            '</div>'
        );

        var percentage = '';
        if (data[i].infoList.length >= 6) {
            percentage = '20%';
        } else {
            percentage = (1 / data[i].infoList.length) * 100 + '%';
        }
        var str = '';
        for (var dataLength = 0; dataLength < data[i].infoList.length; dataLength++) {

            var lightClass = (window.location.href).indexOf(getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc)) >= 0 ? 'cur' : '';
            var lightImgUrl = (window.location.href).indexOf(getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc)) >= 0 ? data[i].infoList[dataLength].infoImgTwo : data[i].infoList[dataLength].infoImgOne;
            str += '<li class="' + lightClass + '" style="width: ' + percentage + '" type="' + data[i].infoList[dataLength].infoSubType + '" onclick="gotoLink(\'' + getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc) + '\')">';

            str += '<div class="pic">' +
                '<img src="' + lightImgUrl + '"/>' +
                '</div>' +
                '<span>' + data[i].infoList[dataLength].infoTitle + '</span>' +
                '</li>';
            sessionStorage.setItem(getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc), data[i].infoList[dataLength].infoTitle);
        };
        $('.area_T' + i).find('ul').append(str);
    }
}

//底部菜单（二）
function footerMenuTwo(data) {

    for (var i = 0; i < data.length; i++) {

        $("#area_T").append(
            '<div class="footerWc area_T' + i + '">' +
            '<ul class="footer"></ul>' +
            '</div>'
        );

        // var percentage = '';
        // if (data[i].infoList.length >= 6) {
        //     percentage = '20%';
        // } else {
        //     percentage = (1 / data[i].infoList.length) * 100 + '%';
        // }
        var str = '';
        for (var dataLength = 0; dataLength < data[i].infoList.length; dataLength++) {

            var lightClass = (window.location.href).indexOf(getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc)) >= 0 ? 'cur' : '';
            var lightImgUrl = (window.location.href).indexOf(getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc)) >= 0 ? data[i].infoList[dataLength].infoImgTwo : data[i].infoList[dataLength].infoImgOne;
            str += '<li class="' + lightClass + '" type="' + data[i].infoList[dataLength].infoSubType + '" onclick="gotoLink(\'' + getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc) + '\')">';

            str += '<div class="pic">' +
                '<img src="' + lightImgUrl + '"/>' +
                '</div>' +
                '<span>' + data[i].infoList[dataLength].infoTitle + '</span>' +
                '</li>';
            sessionStorage.setItem(getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc), data[i].infoList[dataLength].infoTitle);
        };
        $('.area_T' + i).find('ul').append(str);
    }
}

// 头部菜单 （一）
function headMenuOne(data) {

    var index = getUrlParam('index');

    for (var i = 0; i < data.length; i++) {
        $("#area_A").append(
            '<div class="headMenuFixed area_A' + i + '"><div class="headMenuBox clearfix">' +
            '<div class="headMenu fl"><div class="swiper-wrapper">' +
            '</div></div>' +
            '<div class="headFeatures fr"></div>' +
            '<div class="headPopNav">' +
            '<a href="/' + whyConfig.shopPath + '/user/usercenter.html"><img src="' + modulePath + 'image/headNav1.png" width="22" height="22" />个人中心</a>' +
            '<a href="' + '/' + whyConfig.shopPath + '/searchRe.html?sectionId=' + (util.qs('sectionId') || whyConfig.sectionId) + '&areaDataType="><img src="' + modulePath + 'image/headNav2.png" width="22" height="22" />智能搜索</a>' +
            '</div>' +
            '</div></div>'
        );
        var str = '';
        for (var dataLength = 0; dataLength < data[i].infoList.length; dataLength++) {

            var lightClass = (window.location.href).indexOf(getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc)) >= 0 ? 'active' : '';
            str += '<div class="swiper-slide ' + lightClass + '" type="' + data[i].infoList[dataLength].infoSubType + '" onclick="gotoLink(\'' + getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc) + '\')">';
            str += data[i].infoList[dataLength].infoTitle + '</div>';
            sessionStorage.setItem(getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc), data[i].infoList[dataLength].infoTitle);

        };

        $(".area_A" + i).find(".swiper-wrapper").append(str);
        new Swiper('.area_A' + i + ' .headMenu', {
            slidesPerView: 'auto',
            spaceBetween: 40,
            onInit: function (swiper) {
                swiper.slideTo($('.area_A' + i).find(".active").index(), 0, false);
            }
        });
        $(".area_A" + i + ' .headFeatures').on('click', function (e) {
            e = e || e.event;
            e.stopPropagation();
            if ($(this).hasClass('open')) {
                $(this).removeClass('open');
                $(this).siblings('.headPopNav').hide();
            } else {
                $(this).addClass('open');
                $(this).siblings('.headPopNav').show();
            }
        });
        $(".area_A" + i + ' .headPopNav').on('click touchstart', 'a', function (e) {
            e = e || e.event;
            e.stopPropagation();
        });
        $('.area_A' + i + ' .headFeatures').on('click touchstart', function (e) {
            e = e || e.event;
            e.stopPropagation();
        });
        $('html, body').on('click touchstart', function () {
            $('.headFeatures').removeClass('open');
            $('.headPopNav').hide();
        });
    }
}

// 头部菜单 （二）
function headMenuTwo(data) {

    var index = getUrlParam('index');

    util.jsonp(whyConfig.apiUrl + '/apiTerminalUser/checkLogin.do', function (err, res_user) {
        console.log(res_user)
        /*if (res_user&&res_user.status == 200) {
            var user = res_user.data || {};
            this.userId = user.userId || '';
        }*/
        var userImg = ''
        if (res_user && res_user.status == 200 && (res_user.data || {}).userHeadImgUrl) {
            userImg = imgCompress((res_user.data || {}).userHeadImgUrl, '_300_300');
        } else {
            userImg = 'https://culturestore.oss-cn-shanghai.aliyuncs.com/store-m0008/image/grzx.png'
        }
        for (var i = 0; i < data.length; i++) {
            $("#area_A").append(
                '<div class="headMenuFixed area_A' + i + '"><div class="headMenuBox clearfix">' +
                '<div class="headSearWc clearfix">' +
                '<a class="headSear" href="' + '/' + whyConfig.shopPath + '/searchRe.html?sectionId=' + (util.qs('sectionId') || whyConfig.sectionId) + '&areaDataType="><img src="https://culturestore.oss-cn-shanghai.aliyuncs.com/store-m0008/image/fdj1.png">搜索</a>' +
                '<a class="headGrzx" href="/' + whyConfig.shopPath + '/user/usercenter.html"><img style="border-radius: 50%;width: 50px;height: 50px;margin: 0 auto;margin-top: 5px;" src="' + userImg + '"></a>' +
                '</div>' +
                '<div class="headMenu"><div class="swiper-wrapper">' +
                '</div></div>' +
                '</div></div>'
            );
            var str = '';
            for (var dataLength = 0; dataLength < data[i].infoList.length; dataLength++) {

                var lightClass = (window.location.href).indexOf(getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc)) >= 0 ? 'active' : '';

                str += '<div class="swiper-slide ' + lightClass + '" type="' + data[i].infoList[dataLength].infoSubType + '" onclick="gotoLink(\'' + getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc) + '\')">';
                str += data[i].infoList[dataLength].infoTitle + '</div>';

                sessionStorage.setItem(getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc), data[i].infoList[dataLength].infoTitle);
            };

            $('.area_A' + i).find('.swiper-wrapper').append(str);
            new Swiper('.area_A' + i + ' .headMenu', {
                slidesPerView: 'auto',
                spaceBetween: 40,
                onInit: function (swiper) {
                    swiper.slideTo($('.area_A' + i).find(".active").index(), 0, false);
                }
            });
        }

    }.bind(this), false)

}

function menuToggle() {
    if ($('.side-menu-mask').is(":hidden")) {
        $('.side-menu-mask').stop().fadeIn(300);
        $('body,html').css('overflow', 'hidden');
        $('.side-menu').stop().animate({
            left: 0
        }, 300)
    } else {
        $('.side-menu-mask').stop().fadeOut(300);
        $('body,html').css('overflow', 'scroll');
        $('.side-menu').stop().animate({
            left: '-100%'
        }, 300)
    }
}

//侧边菜单
function headMenuThree(data) {


    var index = getUrlParam('index');

    util.jsonp(whyConfig.apiUrl + '/apiTerminalUser/checkLogin.do', function (err, res_user) {
        let name = res_user.status == 500 ? '未登录' : ((res_user.data || {}).userName || '')
        res_user = res_user.data || {};
        let userImg = res_user.userHeadImgUrl || 'https://culturestore.oss-cn-shanghai.aliyuncs.com/store-common/image/user-avatar-2.png'
        let searchUrl = '/' + whyConfig.shopPath + '/searchRe.html?sectionId=' + (util.qs('sectionId') || whyConfig.sectionId) + '&areaDataType='
        let loginUrl = '/' + whyConfig.shopPath + '/user/usercenter.html'
        let menuImg = data[0].contentImg || 'https://culturecloud.oss-cn-hangzhou.aliyuncs.com/wangxiaosong/image/20191225134646MKAy4BKDmc6iaPVAHRWaEZx8kNJxp1.png'
        let menuList = ''

        for (var dataLength = 0; dataLength < data[0].infoList.length; dataLength++) {
            menuList += `
                    <a class="one" href="javascript:    ;" onclick="gotoLink('` + getLink(data[0].infoList[dataLength].infoType, data[0].infoList[dataLength].infoSubType, data[0].infoList[dataLength].infoLinkSrc) + `')">
                        <i class="icon"><img src="` + data[0].infoList[dataLength].infoImgOne + `"></i>
                        <span class="wz">` + data[0].infoList[dataLength].infoTitle + `</span>
                        <i class="iconfont icon-ARROW-right"></i>
                    </a>`

        }

        let menu = `
        <img class="side-menu-float" onclick="menuToggle()"
             src="${menuImg}">
        <div class="side-menu-mask" onclick="menuToggle()" style="display: none;"></div>
        <div class="side-menu" style="left: -100%">
            <div class="grzx">
             
                <div onclick="location.href='${loginUrl}'" class="avatar"><img
                        src="${userImg}">
                </div>     
                <a href="${loginUrl}">          
                <div class="name">
                ${name}
                </div>
                </a>
                <div style="position: absolute;top:10px;right: 20px" onclick="menuToggle()"><span style="color:#f3f3f3;font-size: 24px">收起</span></div>
            </div>
            <div class="scroll-wrap">
                <div class="sear-menu">
                    <i class="iconfont icon-search1"></i>
                    <a href="${searchUrl}">
                        <input class="txtInp" type="text" placeholder="搜索" disabled @click="toSearch">
                    </a>
                </div>
                <div class="menu-list">
                ${menuList}
                </div>
            </div>
        </div>
    `
        $("#area_T").html(menu)

    }.bind(this), false)

}

//云节：头部菜单
function headMenuCity(data) {
    for (var i = 0; i < data.length; i++) {
        $("#area_yj_F").append(
            '<div class="headMenuFixed area_yj_F' + i + '">' +
            '<div class="headMenuBox clearfix">' +
            '<div class="headMenu fl">' +
            '<div class="swiper-wrapper"></div>' +
            '</div>' +
            '<div class="headFeatures fr"><span class="fBtn"></span></div>' +
            '<div class="headPopNav">' +
            '</div>' +
            '</div></div>'
        );

        var query = {
            _url: 'wechatShop/getYjShopList.do',
            shopPath: whyConfig.shopPath,
        }
        var url = whyConfig.baseShopPath + '/store';
        $.post(url, query, function (res) {
            console.log(res);
            var yjLink = '';
            if (!res.data.data || res.data.data.length == 0) return;
            res.data.data.forEach(function (e) {
                yjLink += '<a href="' + e.shopUrl + '"><img src="https://culturestore.oss-cn-shanghai.aliyuncs.com/store-yj0001/image/headNav2.png" width="34" height="34">' + e.shopName + '</a>'
            })
            $(".headPopNav").append(yjLink)
        }, 'json')


        var str = '';
        for (var dataLength = 0; dataLength < data[i].infoList.length; dataLength++) {
            var lightClass = (window.location.href).indexOf(getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc).split('?')[0]) >= 0 ? 'active' : '';

            var link = getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc) + '?v=' + Math.random();
            if (dataLength == 0) {
                str += '<div class="swiper-slide shouye ' + lightClass + '" style="background-image: url(\'' + data[i].infoList[dataLength].infoImgOne + '\')" onclick="window.location=\'' + link + '\'"></div>';
            } else {
                str += '<div class="swiper-slide ' + lightClass + '" onclick="gotoLink(\'' + getLink(data[i].infoList[dataLength].infoType, data[i].infoList[dataLength].infoSubType, data[i].infoList[dataLength].infoLinkSrc) + '\')">' + data[i].infoList[dataLength].infoTitle + '</div>';
            }
        };

        $(".area_yj_F" + i).find(".swiper-wrapper").append(str);

        new Swiper('.area_yj_F' + i + ' .headMenu', {
            slidesPerView: 'auto',
            spaceBetween: 80,
            onInit: function (swiper) {
                swiper.slideTo($('.area_yj_F' + i + ' .headMenu .swiper-slide.active').index(), 0, false);
            }
        });

        $('.area_yj_F' + i + ' .headFeatures').on('click', function (e) {
            e = e || e.event;
            e.stopPropagation();
            if ($(this).hasClass('open')) {
                $(this).removeClass('open');
                $(this).parents('.headMenuBox').find('.headPopNav').hide();
            } else {
                $(this).addClass('open');
                $(this).parents('.headMenuBox').find('.headPopNav').show();
            }
        });
        $('.area_yj_F' + i + ' .headPopNav').on('click touchstart', 'a', function (e) {
            e = e || e.event;
            e.stopPropagation();
        });
        $('.area_yj_F' + i + ' .headFeatures').on('click touchstart', function (e) {
            e = e || e.event;
            e.stopPropagation();
        });
        $('html, body').on('click touchstart', function () {
            $('.headFeatures').removeClass('open');
            $('.headPopNav').hide();
        });
    }

}

//
// function hasNav(_NAVS,name) {
//     if(!_NAVS||_NAVS.length==0)return false;
//     let nav = _NAVS;
//     console.log('nav',nav);
//     let obj={'17':'/train/list.html'};
//     if (!nav.infoList || nav.infoList.length == 0) return false;
//     for (let item of nav.infoList) {
//         if(item.infoType==1){
//             if (item.infoLinkSrc.indexOf(name) != -1) {
//                 return true;
//             }
//         }else {
//             let arr=item.infoSubType.split(',');
//             if(!arr||arr.length!=2) continue;
//             if (obj[arr[0]]&&obj[arr[0]].indexOf(name) != -1) {
//                 return true;
//             }
//         }
//     }
//     return false;
// }


function isNav(arrs, name) {

    if (!arrs || arrs.length == 0) return false;
    let nav = arrs;
    let obj = {
        '13': '/assn/assnlist.html',
        '17': '/train/list.html',
        '36': '/events/list.html',
        '26': '/releaseRaise/list.html',
        '24': '/voluntaryService/activity.html',
        '25': '/voluntaryService/list.html',
        '241': '/voluntaryService/index.html?code=4',
        '251': '/voluntaryService/index.html?code=5',
        '29': '/mooc/trainList.html',
        '35': '/peisong/index.html', //配送列表（沈阳版）
        '41': '/commodity/list.html', // 文创
        '50': '/microphone/list.html',
        '54': '/cloudTrain/index.html', //saas我的订单
        '54': '/cloudTrain/index.html', //saas我的课程
        '55': '/peisong/iSend.html', //你点我送
        '33': '/bjmk/list.html',
        '59': '/organization/index.html',
        '62': '/teachers/list.html',
        '63': '/hnps/delivery/delivery.html',
        '64': '/hnps/cultural/list.html',
        '65': '/hnps/serve/list.html',
        '66': '/trains/index.html',
        '73': '/repository/list.html',
        '74': '/micro-specialty/list.html',
    };
    for (let item of arrs) {
        if (item.infoType == 1) {
            if (item.infoLinkSrc.indexOf('szmk') != -1 && name == '/szmk/') {
                return true
            } else if (item.infoLinkSrc.indexOf('collectWorks') != -1 && name == '/mywork/') { // 没有mywork 都是collcetworks?
                return true
            } else if (item.infoLinkSrc.indexOf(name) != -1) {
                return true;
            }
        } else if (item.infoType == 2) {
            let arr = item.infoSubType.split(',');
            if (!arr || arr.length != 2) continue;
            if (obj[arr[0]] && obj[arr[0]].indexOf(name) != -1) {
                return true;
            }
        } else {
            if (!item.infoList || item.infoList.length == 0) continue;
            let hasIt = isNav(item.infoList, name);
            if (hasIt) return true;
            // return isNav(item.infoList, name);
        }
    }
    if (!nav.infoList || nav.infoList.length == 0) return false;
    return isNav(nav.infoList, name);
}


function checkNav(data) {
    let arr = [
        'mooc',
        'commodity',
        'voluntaryService',
        'train',
        'venueHasBook',
        'feedback',
        'cultrue-volunteer',
        'mywork',
        'releaseRaise',
        'events',
        'venueTicket',
        'brokenRecord',
        'attention',
        'interestCardAuth',
        'microphone',
        'myorder',
        'cloudTrain',
        'peisong',
        'bjmk',
        'organization',
        'teachers',
        'hnps',
        'assn',
        'activityRoomParentAuth',
        'peixunLiaoningInterviewAuth',
        'openUserTeam',
        'my-certificates',
        'openJiaowuAuth',
        'openXiaowuAuth',
        'smsAuth',
        'authentication',
        'szmk'
    ];
    for (let item of arr) {
        setTimeout(() => {
            if (isNav(data, '/' + item + '/')) {
                $('.' + item).css('display', 'block');
            } else {
                $('.' + item).css('display', 'none');
            }
        }, 0)
    }
}

function getNav(type = false) {
    let getH5EntranceInfoSession = sessionStorage.getItem(whyConfig.shopProvince + '_' + whyConfig.shopPath + '_getH5EntranceInfo');
    if (type) {
        getH5EntranceInfoSession = null;
    }
    if (getH5EntranceInfoSession) {
        checkNav(JSON.parse(getH5EntranceInfoSession))
    } else {
        $.post('/' + whyConfig.shopPath + '/getH5EntranceInfo', {}).then((res) => {
            if (!res.data || res.data.length == 0) return;
            sessionStorage.setItem(whyConfig.shopProvince + '_' + whyConfig.shopPath + '_getH5EntranceInfo', JSON.stringify(res.data));
            checkNav(res.data)
        })
    }
}


// 菜单（公共方法）
// number无用原逻辑，type 刷新数据权限
function menuCommon(modelCode, number = 0, type = false) {
    getNav(type)
    if (modelCode == 'm0001' || modelCode == 'm0004' || modelCode == 'm0005' || modelCode == 'm0007' || modelCode == 'm0009' || modelCode == 'm0010') {
        getData(whyConfig.shopPath, 'area_T', modelCode, function (data) {
            // checkNav(data)
            footerMenu(data);
        });
    } else if (modelCode == 'm0002' || modelCode == 'm0006') {
        getData(whyConfig.shopPath, 'area_A', modelCode, function (data) {
            headMenuOne(data); //90
        });
    } else if (modelCode == 'm0003' || modelCode == 'm0008') {
        getData(whyConfig.shopPath, 'area_A', modelCode, function (data) {
            headMenuTwo(data); //174
        });
    } else if (modelCode == 'm0012') {
        getData(whyConfig.shopPath, 'area_AB', modelCode, function (data) {
            headMenuThree(data);
        });
    } else if (modelCode == 'm0013') {
        getData(whyConfig.shopPath, 'area_T', modelCode, function (data) {
            footerMenuTwo(data);
        });
    } else if (modelCode == 'yj0001' || modelCode == 'yj0002' || modelCode == 'yj0003' || modelCode == 'yj0004') {
        getData(whyConfig.shopPath, 'area_yj_F', modelCode, function (data) {
            headMenuCity(data);
        });
    }
}

//判断是否是微信浏览器
function is_weixin() {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == "micromessenger") {
        return true;
    } else {
        return false;
    }
}
//判断是否是郑好办
function is_zhenghaoban() {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/izzzwfwapp/i) == "izzzwfwapp") {
        return true;
    } else {
        return false;
    }
}

//判断是否是深圳第三方
function sendPostMessage() {
    let userAgent = getUrlParam('userAgent');
    if (userAgent && userAgent == 'isSZSMT') {
        sessionStorage.setItem('userAgent', userAgent);
        shenzenLogin()
        shenzhenPostMessage()
    } else {
        let userAgent = sessionStorage.getItem('userAgent');
        if (userAgent && userAgent == 'isSZSMT') {
            shenzhenPostMessage()
        }
    }
}
function shenzhenPostMessage() {
    window.parent.postMessage({
        type: "setViewport",
        data: "width=750,user-scalable=no"
    }, '*');
}
// 对接第三方登录
function shenzenLogin() {
    // if (getUrlParam('AccessToken')) {
    //     var proxy = '/' + whyConfig.shopPath + '/api';
    //     $.post(proxy, {
    //         _url: '/szwenUser/oneClickBookingPlatform.do',
    //         shopPath: whyConfig.shopPath,
    //         accessToken: getUrlParam('AccessToken')
    //     }).then(res => {
    //         sessionStorage.setItem('USERINFO', JSON.stringify(decodeAesString(res.data.data)));
    //     })
    // }
}
function ZhbJssdkReady(callback) {
    if (window.AlipayJSBridge) {
        callback && callback();
    } else {
        document.addEventListener('AlipayJSBridgeReady', callback, false);
    }
}

window.onload = function () {
    // var vConsole = new VConsole();
    if (is_zhenghaoban()) {
        $.post('/' + whyConfig.shopPath + '/sess', {}).then((res) => {
            if (!res || !res.data || !res.data.userId) {
                ZhbJssdkReady(function () {
                    var moduleId = "897"; // 正式：897 测试：26748
                    AlipayJSBridge.call('userAuth', {
                        "moduleId": moduleId,
                        "scope": "userInfo"
                    }, function (res) {
                        if (res.code == 0) {
                            var url = location.origin + '/' + whyConfig.shopPath + '/setSession.html?url=' + window.location.href;
                            url = util.encodeUrl(url);
                            location.href = whyConfig.apiUrl + '/digitalcnzzUser/authorize.do' + '?authCode=' + res.data.authCode + '&moduleId=' + moduleId + '&shopPath=' +
                                whyConfig.shopPath + '&callback=' + url;
                            // var query = {
                            //     authCode: res.data.authCode,
                            //     moduleId: moduleId,
                            //     callback: window.location.href,
                            //     shopPath: whyConfig.shopPath,
                            //     _url: whyConfig.apiUrl + '/digitalcnzzUser/authorize.do',
                            // }
                            // var proxy = '/' + whyConfig.shopPath + '/proxy';
                            // $.post(proxy, query, function (data) {
                            //     console.log('data----- :>> ', data);
                            //     if(data.data.status == 200) {
                            //         if(data.data.data) {
                            //             alert(JSON.stringify(data.data.data))
                            //             window.location.href = location.origin + '/' + whyConfig.shopPath + '/setSession.html?url=' + window.location.href +'&userId='+data.data.data;
                            //         } else {
                            //             dialogAlert('提示', data.data.data);
                            //         }
                            //     }
                            // }, "json");
                        }
                        //   else {
                        //     AlipayJSBridge.call('exitApp');
                        //   }
                    })
                });
            }
        })
    }
    sendPostMessage();
}


//分享获得积分
function shareIntegral(url, actId, shareType, that) {
    if (shareType == 999) { // 短视频分享
        that.shareAddOne()
        return
    }
    if (actId) { // 分享次数增加
        let condition = {
            _url: '/apiObjectStatistics/addShareCount.do',
            shopPath: whyConfig.shopPath,
            id: actId,
            type: shareType
        }
        let gateway_url = '/' + whyConfig.shopPath + '/proxy';
        return new Promise(function (resolve, reject) {
            $.ajax({
                url: gateway_url,
                type: 'POST',
                dataType: 'json',
                contentType: "application/json",
                data: JSON.stringify(condition),
                success: function (res) { },
                error: function (err) { }
            })
        })
    }
    if (userId) {
        var proxy = '/' + whyConfig.shopPath + '/proxy';
        $.post(proxy, {
            _url: '/wechatUser/forwardingIntegral.do',
            url: url,
            userId: userId
        })
    }
}
//公共分享方法    // actId shareType  增加了分享次数 前面那个活动id 后面那个分享类型   shareType 999 短视频分享  用于测试缓存标记 等待验证
function publicShare(title, desc, contentCode, matchMode, imgSrc, shareUrl = window.location.href, appShare, actId, shareType, that) {
    var shareData = {
        contentCode: contentCode,
        matchMode: matchMode,
        url: window.location.href.indexOf('setSession.html') != -1 ? window.origin + '/' + whyConfig.shopPath + '/index.html' : window.location.href,
    };

    var returnData = {}
    return new Promise(function (resolve, reject) {
        const storeUrl = whyConfig.mdUrl.split('//')[1];
        const urls = storeUrl.split(':')[0]
        $.ajax({
            type: "post",
            data: shareData,
            url: `${window.location.protocol}//${urls}` + '/' + whyConfig.shopPath + '/wechat/getWxSign.do',
            dataType: "json",
            contentType: "application/x-www-form-urlencoded",
            success: function (res) {
                var data = res || {};
                title = data.shareTitle ? data.shareTitle : title;
                desc = data.shareDesc ? data.shareDesc : desc;
                appShareTitle = title;
                appShareDesc = desc;

                if (imgSrc) {
                    imgUrl = imgSrc;
                } else if (data.shareImg) {
                    imgUrl = data.shareImg
                } else if (data.shopHeadImg) {
                    imgUrl = data.shopHeadImg;
                } else {
                    imgUrl = "https://culturecloud.oss-cn-hangzhou.aliyuncs.com/H5/2018227174158On0E1yhvd0bcmrx2bulKYVz0T5lyNb.png";
                }

                if (is_weixin()) {
                    wx.config({
                        debug: false,
                        appId: data.appId,
                        timestamp: data.timestamp,
                        nonceStr: data.nonceStr,
                        signature: data.signature,
                        jsApiList: ['previewImage', 'onMenuShareAppMessage', 'onMenuShareTimeline', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'getNetworkType', 'getLocation']
                    });

                    wx.ready(function () {
                        wx.onMenuShareAppMessage({
                            title: title,
                            desc: desc,
                            imgUrl: imgUrl,
                            link: shareUrl || '',
                            success: function () {
                                // 幸运翻翻乐 分享成功可增加抽奖次数
                                // if (that.lotShare) {
                                //     that.lotShare()
                                // }
                                console.log('分享success', shareUrl)
                                if (shareUrl || actId) {
                                    shareIntegral(shareUrl, actId, shareType, that);
                                }
                                if (drawShare) {
                                    $.post(proxy, {
                                        _url: '/apiDraw/shareAddChance.do',
                                        userId: user.userId,
                                    }, function (res) {
                                        console.log(res);
                                        window.location.reload();
                                    })
                                }
                            }
                        });
                        wx.onMenuShareTimeline({
                            title: title,
                            imgUrl: imgUrl,
                            success: function () {
                                if (shareUrl || actId)
                                    shareIntegral(shareUrl, actId, shareType, that);
                            }
                        });
                        wx.onMenuShareQQ({
                            title: title,
                            desc: desc,
                            imgUrl: imgUrl,
                            success: function () {
                                if (shareUrl || actId)
                                    shareIntegral(shareUrl, actId, shareType, that);
                            }
                        });
                        wx.onMenuShareWeibo({
                            title: title,
                            desc: desc,
                            imgUrl: imgUrl,
                            success: function () {
                                if (shareUrl || actId)
                                    shareIntegral(shareUrl, actId, shareType, that);
                            }
                        });
                        wx.onMenuShareQZone({
                            title: title,
                            desc: desc,
                            imgUrl: imgUrl,
                            success: function () {
                                if (shareUrl || actId)
                                    shareIntegral(shareUrl, actId, shareType, that);
                            }
                        });
                        wx.getNetworkType({
                            success: function (res) {
                                var networkType = res.networkType; // 返回网络类型2g，3g，4g，wifi
                                if (networkType != 'wifi') {
                                    returnData.isWifi = false;
                                } else {
                                    returnData.isWifi = true;
                                }
                                return resolve(returnData)
                            }
                        });
                    });

                } else {
                    // 分享是否隐藏
                    var app_sdk = window.injs ? window.injs : window.whySDK;
                    if (app_sdk) {
                        // 分享文案
                        appShareTitle = title;
                        appShareDesc = desc;
                        appShareImgUrl = imgUrl;

                        if (typeof app_sdk.setAppShareButtonStatus == 'function') {
                            app_sdk.setAppShareButtonStatus(true);
                        } else if (typeof app_sdk.invokeNative == 'function') {
                            app_sdk.invokeNative('setAppShareButtonStatus', '{ "isShow" : "1" }');
                        }
                    }
                }
            }
        });
    })
}

//APP获取分享信息
function getShareInfo() {
    var shareJson = {
        title: appShareTitle,
        desc: appShareDesc,
        imgUrl: imgUrl,
        link: window.location.href
    };
    return JSON.stringify(shareJson);
}

function appShareButtonClick() {
    if (window.injs) {
        //var shareInfo = '{"link" : "' + window.location.href + '", "imgUrl" : "' + imgUrl + '", "title : "' + appShareTitle + '", "desc" : "' + appShareDesc + '"}';
        var shareInfo = {
            link: window.location.href,
            imgUrl: imgUrl,
            title: appShareTitle,
            desc: appShareDesc
        }
        shareInfo = JSON.stringify(shareInfo)
        injs.shareByApp(shareInfo);
    }
}

/* star 点击查看大图 */
function previewImg(url, urls, Suffix) {
    var urlArray = new Array();
    if (urls.indexOf(";") >= 0) urlArray = urls.split(";");
    //	if(urls.indexOf(";") >= 0) urlArray = urls.split(";");
    //	else if(urls.indexOf(",") >= 0) urlArray = urls.split(",");

    if (Suffix) {
        url += Suffix;
        var previewImgs = "";
        $.each(urlArray, function (i, dom) {
            previewImgs += dom + Suffix + ";";
        });
        if (urlArray.length > 0) {
            urls = previewImgs.substring(0, previewImgs.length - 1);
        }
    } else {
        var previewImgs = "";
        $.each(urlArray, function (i, dom) {
            previewImgs += dom + ";";
        });
        if (urlArray.length > 0) {
            urls = previewImgs.substring(0, previewImgs.length - 1);
        }
    }
    if (is_weixin()) {
        wx.previewImage({
            current: url, // 当前显示图片的http链接
            urls: urls.split(";") // 需要预览的图片http链接列表
        });
    } else {
        if (!(/wenhuayun/.test(ua)) || !window.injs || !injs.appPhotoBrowser(url, urls)) { //判断是否存在APP方法
            showSwiperPreview(url, urls);
        }
    }
}

//swiper图片预览（不可缩放）
function showSwiperPreview(url, urls) {
    var imgSrc = urls.split(';');
    var slideAmount = imgSrc.length;
    var ele_s1 = $('.roomBigPic .amount .s1');
    $('.roomBigPic .amount .s2').html(slideAmount);
    var _index = 0;
    for (var i = 0; i < slideAmount; i++) {
        if (imgSrc[i] == url) {
            _index = i;
        }
    }

    if (springSwiperFlag == 0) {
        outSwiper = new Swiper('.roomBigPic .swiper-container', {
            lazyLoading: true,
            lazyLoadingInPrevNext: true,
            observer: true,
            onInit: function (inSwiper) {
                for (var i = 0; i < slideAmount; i++) {
                    inSwiper.appendSlide('<div class="swiper-slide"><img class="swiper-lazy" data-src="' + imgSrc[i] + '"><div class="swiper-lazy-preloader"></div></div>');
                }

                inSwiper.slideTo(_index, 0, false);
                ele_s1.html(inSwiper.activeIndex + 1);
            },
            onSlideChangeEnd: function (inSwiper) {
                ele_s1.html(inSwiper.activeIndex + 1);
            }
        });
        springSwiperFlag = 1;
    } else {
        outSwiper.removeAllSlides();
        for (var i = 0; i < slideAmount; i++) {
            outSwiper.appendSlide('<div class="swiper-slide"><img class="swiper-lazy" data-src="' + imgSrc[i] + '"><div class="swiper-lazy-preloader"></div></div>');
        }
        outSwiper.slideTo(_index, 0, false);
        ele_s1.html(outSwiper.activeIndex + 1);
    }

    $('.roomBigPic').stop().fadeIn(80);
}

//初始化swiper Div
function initSwiper() {
    var zongtxt = '<div class="roomBigPic" style="display:none;"><div class="amount"><span class="s1"></span> / <span class="s2"></span></div><div class="swiper-container"><div class="swiper-wrapper"></div></div></div>';
    $('body').append(zongtxt);
    $(".roomBigPic").on("touchmove", function () {
        return false;
    });
    $(".roomBigPic").on("click", function () {
        $(this).fadeOut(80);
    });
}

/* star 点击查看大图 */


//图片前缀
function getImgUrl(imgurl) {
    return whyConfig.staticServerUrl + '/' + imgurl;
}

//点击查看视频
function showVideo(src) {
    $('#videoBoxPop').show();
    $('#videoBoxPop video').attr('src', src);
    $('#videoBoxPop video').get(0).play();

    $('#videoBoxPop .close').on('click', function () {
        $('#videoBoxPop').hide();
        $('#videoBoxPop video').removeAttr('src');
        $('#videoBoxPop video').get(0).pause();
    });
}

function initVideo() {
    $('body').append('<div id="videoBoxPop" style="width: 750px;height: 100%;position: fixed;top: 0;right: 0;bottom: 0;left: 0;margin: auto;z-index: 200;background-color: rgba(0,0,0,.8);display: none;">' +
        '<video src="" controls="controls" style="display: block;width: 100%;height: auto;position: absolute;top: 0;right: 0;bottom: 0;left: 0;margin: auto;"></video>' +
        '<div class="close" style="width: 100px;height: 100px;background: url(https://culturecloud.oss-cn-hangzhou.aliyuncs.com/video/201832018612IbO8QKZXXLeaNI1MTRBI7EdRrJz2to.png) no-repeat center;position: absolute;right: 0;top: 0;"></div>' + '</div>');
}

//跳转活动室详情
function toRoomDetail(roomId) {
    if (/wenhuayun/.test(ua)) { //APP端
        if (window.injs) { //判断是否存在方法
            injs.accessAppPage(3, roomId);
        } else {
            location.href = "com.wenhuayun.app://roomdetail?roomId=" + roomId;
        }
    } else { //H5
        // window.parent.location.href = whyConfig.whyUrl + "/wechatRoom/preRoomDetail.do?roomId=" + roomId + '&shopPath=' + whyConfig.shopPath;
        window.location.href = whyConfig.baseShopPath + "/room/detail.html?id=" + roomId;

    }
}

//跳转到活动详情页
function toActDetail(activityId, sysUrl) {
    if (/wenhuayun/.test(ua)) { //APP端
        if (window.injs) { //判断是否存在方法
            injs.accessAppPage(1, activityId);
        } else {
            location.href = "com.wenhuayun.app://activitydetail?activityId=" + activityId;
        }
    } else { //H5
        if (!sysUrl) {
            location.href = whyConfig.baseShopPath + '/activity/detail.html?id=' + activityId;
            //window.parent.location.href = whyConfig.whyUrl + "/wechatActivity/preActivityDetail.do?activityId=" + activityId + '&shopPath=' + whyConfig.shopPath;
        } else {
            window.parent.location.href = sysUrl;
        }
    }
}

//跳转到场馆详情页
function toVenueDetail(venueId) {
    if (/wenhuayun/.test(ua)) { //APP端
        if (window.injs) { //判断是否存在方法
            injs.accessAppPage(2, venueId);
        } else {
            location.href = "com.wenhuayun.app://venuedetail?venueId=" + venueId;
        }
    } else { //H5
        window.parent.location.href = whyConfig.baseShopPath + '/venue/detail.html?id=' + venueId;
        //window.parent.location.href = whyConfig.whyUrl + "/wechatVenue/venueDetailIndex.do?venueId=" + venueId + '&shopPath=' + whyConfig.shopPath;
    }
}


function setTuser(userId) {
    $.post('/' + whyConfig.shopPath + '/web/tuser', {
        tuid: userId
    }, function (res) {
        console.log('tuser', res)
    }, "json");
}

//跳转资讯详情
function toInformationDetail(informationId) {
    location.href = whyConfig.baseShopPath + '/infolist/detail.html?id=' + informationId;
}

//跳转艺术鉴赏详情
function toAntiqueDetail(antiqueId) {
    location.href = whyConfig.baseShopPath + '/antique/detail.html?id=' + antiqueId;
}

//跳转社团详情
function toAssnDetail(assnId) {
    location.href = whyConfig.baseShopPath + '/assn/detail.html?id=' + assnId;
}

//跳转到培训详情
function toTrainDetail(id) {
    location.href = whyConfig.baseShopPath + '/train/detail.html?id=' + id;
}

//跳转到配送详情
function toDistributionDetail(orderId) {
    location.href = whyConfig.baseShopPath + '/distribution/detail.html?orderId=' + orderId;
}

//跳转到志愿者详情
function toVolunteerDetail(id) {
    location.href = whyConfig.baseShopPath + '/volunteer/detail.html?id=' + id;
}

// 获取链接：用来菜单栏高亮的样式匹配
function getLink(infoType, infoSubType, infoLinkSrc) {
    // infoType：1（外链） 2（内链） 3（啥都不做）
    // infoSubType 跳转到哪里
    // infoLinkSrc 跳转的链接
    if (infoType == 1) {
        return infoLinkSrc;
    } else if (infoType == 2) {
        var type = parseInt(infoSubType.split(',')[0]);
        switch (type) {
            //正在建设中
            case -1:
                return '/' + whyConfig.shopPath + '/user/build.html';
            case 1: //场馆详情
                return whyConfig.baseShopPath + '/venue/detail.html?id=' + infoLinkSrc;
            case 2: //活动详情
                return whyConfig.baseShopPath + '/activity/detail.html?id=' + infoLinkSrc;
            case 3: //艺术鉴赏详情
                return whyConfig.baseShopPath + '/antique/detail.html?id=' + infoLinkSrc;
            case 4: //资讯详情
                return whyConfig.baseShopPath + '/infolist/detail.html?id=' + infoLinkSrc;
            case 5: //社团详情
                return whyConfig.baseShopPath + '/assn/detail.html?id=' + infoLinkSrc;
            case 6: //首页
                return '/' + whyConfig.shopPath + '/index.html';
            case 7: //搜索
                return "/" + whyConfig.shopPath + '/searchRe.html?sectionId=' + (util.qs('sectionId') || whyConfig.sectionId) + '&areaDataType=' + '';
            case 8: //个人中心
                return '/' + whyConfig.shopPath + '/user/usercenter.html';
            case 9: //场馆列表
                return '/' + whyConfig.shopPath + '/venue/venuelist.html';
            case 10: //活动列表
                return '/' + whyConfig.shopPath + '/activity/actlist.html';
            case 11: //艺术鉴赏列表
                return '/' + whyConfig.shopPath + '/antique/antiquelist.html';
            case 12: //资讯列表
                return '/' + whyConfig.shopPath + '/infolist/infolist.html?informationModuleId=' + infoLinkSrc;
            case 13: //社团列表
                return '/' + whyConfig.shopPath + '/assn/assnlist.html';
            case 14: //地图
                return '/' + whyConfig.shopPath + '/venue/map.html';
            case 15: //志愿者
                return '/' + whyConfig.shopPath + '/volunteer/list.html';
            case 16: //直播
                return whyConfig.apiUrl + '/wechatLive/' + whyConfig.shopPath + 'index.do';
            case 17: //培训
                return '/' + whyConfig.shopPath + '/train/list.html';
            case 18: //配送
                return '/' + whyConfig.shopPath + '/distribution/list.html';
            case 19: // 培训
                return '/' + whyConfig.shopPath + '/onlineTrain/index.html';
            case 20: //数字阅读
                return '/' + whyConfig.shopPath + '/read/list.html';
            case 21: //问卷调查
                return '/' + whyConfig.shopPath + '/survey/list.html';
            case 22: //培训视频
                return '/' + whyConfig.shopPath + '/muke/index.html';
            case 23: //电子杂志
                return '/' + whyConfig.shopPath + '/ebook/list.html';
            case 24: //志愿者活动（湖南版）
                return '/' + whyConfig.shopPath + '/voluntaryService/activity.html';
            case 241: //志愿者活动新版
                return '/' + whyConfig.shopPath + '/voluntaryService/index.html?code=4';
            case 25: //志愿者团队（湖南版）
                return '/' + whyConfig.shopPath + '/voluntaryService/list.html';
            case 251: //志愿者团队新版
                return '/' + whyConfig.shopPath + '/voluntaryService/index.html?code=5';
            case 26: //文化众筹
                return '/' + whyConfig.shopPath + '/releaseRaise/list.html';
            case 27: //百姓点单
                return '/' + whyConfig.shopPath + '/baixin/list.html';
            case 28: //文化非遗（湖南版）
                return '/' + whyConfig.shopPath + '/heritage/index.html';
            case 29: //线下培训列表（辽宁版）
                return '/' + whyConfig.shopPath + '/mooc/trainList.html';
            case 30: //线上培训列表（辽宁版）
                return '/' + whyConfig.shopPath + '/mooc/onlineTrainList.html';
            case 31: //志愿者活动（青岛版）
                return '/' + whyConfig.shopPath + '/cultrue-volunteer/index.html';
            case 32: //志愿者团队（青岛版）
                return '/' + whyConfig.shopPath + '/cultrue-volunteer/index.html';
            case 33: //内部培训（北京朝阳版）
                return '/' + whyConfig.shopPath + '/bjmk/index.html';
            case 34: // 内部培训（辽宁版）
                return '/' + whyConfig.shopPath + '/mooc/innerTrainSearch.html';
            case 35: //配送列表（沈阳版）
                return '/' + whyConfig.shopPath + '/peisong/index.html';
            case 36:
                return '/' + whyConfig.shopPath + '/events/list.html';
            case 37:
                return '/' + whyConfig.shopPath + '/events/solicitationList.html?id=' + infoLinkSrc;
            case 38:
                return '/' + whyConfig.shopPath + '/szmk/index.html';
            case 39:
                return '/' + whyConfig.shopPath + '/learnZone/list.html';
            case 40:
                return '/' + whyConfig.shopPath + '/calendar/list.html';
            case 41: // 文创
                return '/' + whyConfig.shopPath + '/commodity/list.html';
            case 42: // 数字展览
                return '/' + whyConfig.shopPath + '/digitalExhibition/digital-exhibition.html';
            case 43: // 线上投票
                return '/' + whyConfig.shopPath + '/vote/list.html';
            case 44: // 特色文化
                return '/' + whyConfig.shopPath + '/distinctiveCulture/list.html';
            case 45: // 活动抽签
                return '/' + whyConfig.shopPath + '/draw/drawPage.html';
            case 46: // 关注
                return '/' + whyConfig.shopPath + '/user/attention.html';
            case 161: // 直播列表
                return '/' + whyConfig.shopPath + '/video/list.html';
            case 162: // 直播详情
                return '/' + whyConfig.shopPath + '/video/detail.html?id=' + infoLinkSrc;
            case 49: //品牌
                return '/' + whyConfig.shopPath + '/brandActive/list.html';
            case 50: // 金话筒
                return '/' + whyConfig.shopPath + '/microphone/list.html';
            case 51: // 志愿者项目
                return '/' + whyConfig.shopPath + '/volunteerProject/list.html';
            case 52: // 志愿者招募
                return '/' + whyConfig.shopPath + '/volunteerRecruitment/list.html';
            case 53: // 志愿者爱心榜单
                return '/' + whyConfig.shopPath + '/volunteerLovelist/list.html';
            case 54: // 文化培训测试
                return '/' + whyConfig.shopPath + '/arttrain/index.html';
            case 55: // 你点我送
                return '/' + whyConfig.shopPath + '/peisong/list.html';
            case 56: // 配送排行榜
                return '/' + whyConfig.shopPath + '/volunteeISend/list.html';
            case 57: // 配送志愿者团队
                return '/' + whyConfig.shopPath + '/voluntaryService/index.html?code=5';
            case 59: // 文采会参展商
                return '/' + whyConfig.shopPath + '/organization/index.html';
            case 60: // 文采会产品
                return '/' + whyConfig.shopPath + '/richMeet/productList.html';
            case 61: // 短视频
                return '/' + whyConfig.shopPath + '/main/svideo.html';
            case 62: // 师资预约
                return '/' + whyConfig.shopPath + '/teachers/list.html';
            case 63: // 文化豫约申报
                return '/' + whyConfig.shopPath + '/hnps/delivery/delivery.html';
            case 64: // 文化豫约产品列表
                return '/' + whyConfig.shopPath + '/hnps/cultural/list.html';
            case 65: // 文化豫约主体列表
                return '/' + whyConfig.shopPath + '/hnps/serve/list.html';
            case 66: // 培训聚合页
                return '/' + whyConfig.shopPath + '/trains/index.html';
            case 67: // 联盟列表
                return '/' + whyConfig.shopPath + '/alliance/provinceList.html';
            case 68: // 联盟详情
                return '/' + whyConfig.shopPath + '/alliance/detail.html?shopId=' + infoLinkSrc;
            case 70: // 活动列表6.0
                return `${whyConfig.ssFiveApi}/sh_sh/activityoverlay/list-upgrade.html`;
            case 71: // 场馆列表5.0
                return `${whyConfig.ssFiveApi}/sh_sh/venueoverlay/list.html?ciType=6`;
            case 72: // 个人中心6.0
                return `${whyConfig.ssFiveApi}/sh_sh/mine/mine-upgrade.html`;
            case 73: // 培训资源
                return '/' + whyConfig.shopPath + '/repository/list.html';
            case 74: // 微专业
                return '/' + whyConfig.shopPath + '/micro-specialty/list.html';

        }
    } else {
        return '';
    }
}

// 跳链接
function gotoLink(url) {
    // 泉州兼容图书馆登录打通
    if (url && url.includes('old.qzculture.cn/wechatInformation/szts.do')){
        $.post('/' + whyConfig.shopPath + '/sess', {}).then((res) => {
            if (res && res.data && res.data.userId) {
                window.location = url + "?id=" + res.data.userId
            } else {
                window.location = 'https://fujian.ctwenhuayun.cn/muser/login.do?type=https%3A%2F%2Fwww.qzculture.cn%2Fcomquanzhouwhy%2FsetSession.html%3Furl%3Dhttps%253A%252F%252Fwww.qzculture.cn%252Fcomquanzhouwhy%252Findex.html'
            }
        })
    }
    if (url) window.location = url;
}

//contentCode 的跳转
function toCodeLink(contentCode, infoId, infoList) { //  infoList 获取资讯类型 字符串分割
    if (contentCode == 'huodong' || contentCode == 'lishihuodong') {
        // 精彩活动 & 历史活动
        toActDetail(infoId);

    } else if (contentCode == 'changguan') {
        //热门空间
        toVenueDetail(infoId);

    } else if (contentCode.split('_')[0] == 'zx') {
        //文化资讯 【G】 & 非遗传承 【G】
        if (!infoList) {
            infoList = ','
        }
        let infoUploadType = infoList.split(',')[0]
        let infoLinkSrc = infoList.split(',')[1]
        if (infoUploadType == 6) {
            window.location.href = "http://culturecloud.oss-cn-hangzhou.aliyuncs.com/4.0/pdf/web/viewer.html?file=" + infoLinkSrc
        } else {
            toInformationDetail(infoId);
        }


    } else if (contentCode == 'zhuantihuodong') {
        //专题活动
        window.location.href = whyConfig.whyUrl + '/template/activityTopicDetail.do?topicid=' + infoId;

    } else if (contentCode == 'zhibo') {
        //文化直播 【G】
        window.location.href = whyConfig.baseShopPath + '/video/detail.html?id=' + infoId;
    } else if (contentCode == 'huodongshi') {
        //活动室
        toRoomDetail(infoId);
    } else if (contentCode == 'zhishiwenda') {
        //知识问答
    } else if (contentCode == 'yishujianshang') {
        //艺术鉴赏
        toAntiqueDetail(infoId)
    } else if (contentCode == 'wenhuashetuan') {
        //文化社团
        toAssnDetail(infoId)
    } else if (contentCode == 'xianshangtoupiao') {
        //线上投票
    } else if (contentCode == 'zhiyuanzhe') {
        //文化志愿者
        toVolunteerDetail(infoId)
    } else if (contentCode == 'peixun') {
        //培训详情
        toTrainDetail(infoId)
    } else if (contentCode == 'wenhuarili') {
        //文化日历
    } else if (contentCode == 'xianshangzhanlan') {
        //线上展览
    } else if (contentCode == 'zk_') {
        //顶部菜单、广告位、入口位、推荐位、底部菜单
    } else if (contentCode == 'zhibo_given') {
        //直播-给定ID
        window.location.href = whyConfig.baseShopPath + '/video/detail.html?id=' + infoId;
    } else if (contentCode == 'shipin_given') {
        //视频-给定ID
        window.location.href = whyConfig.baseShopPath + '/video/detail.html?id=' + infoId;
    } else if (contentCode == 'zixun_given') {
        //资讯-给定ID
        toInformationDetail(infoId);
    } else if (contentCode == 'changguan_given') {
        //场馆-给定ID
        toVenueDetail(infoId);
    } else if (contentCode == 'zhiyuanzhe_qingdao') {
        //志愿者（青岛）
        window.location.href = whyConfig.baseShopPath + '/volunteer/detail.html?id=' + infoId;
    } else if (contentCode == 'peixun_liaoning') {
        //线下培训（辽宁）
        window.location.href = whyConfig.baseShopPath + '/mooc/trainDetail.html?id=' + infoId;
    } else if (contentCode == 'shuziyuedu') {
        //数字阅读
        if (link.indexOf('.pdf') > 0) {
            window.location.href = "https://culturecloud.oss-cn-hangzhou.aliyuncs.com/4.0/pdf/web/viewer.html?file=" + link
        } else {
            window.location.href = link;
        }
    } else if (contentCode == 'dianzizazhi') {
        //电子杂志(青岛)
        if (link.indexOf('.pdf') > 0) {
            window.location.href = "https://culturecloud.oss-cn-hangzhou.aliyuncs.com/4.0/pdf/web/viewer.html?file=" + link
        } else {
            window.location.href = link;
        }
    } else if (contentCode == 'muke_shenzhen') {
        //文化慕课（深圳）
        window.location.href = whyConfig.baseShopPath + '/szmk/detail.html?id=' + infoId;
    } else if (contentCode == 'feiyi_hunan') {
        //非遗名录（湖南）
        window.location.href = whyConfig.baseShopPath + '/heritage/directory-source-detail.html?id=' + infoId;
    } else if (contentCode == 'wenjuandiaocha') {
        //问卷调查
        window.location.href = whyConfig.baseShopPath + '/survey/detail.html?id=' + infoId;
    } else if (contentCode == 'wenchuang') {
        //文创
        window.location.href = whyConfig.baseShopPath + '/commodity/detail.html?id=' + infoId;
    } else if (contentCode == 'zhiyuan_hunan') {
        //志愿者活动 
        window.location.href = whyConfig.baseShopPath + '/voluntaryService/activityDetail.html?id=' + infoId;
    } else if (contentCode == 'peisongzhiyuanzhetuandui') {
        //配送志愿者团队 
        window.location.href = whyConfig.baseShopPath + '/voluntaryService/listDetail.html?id=' + infoId;
    } else if (contentCode == 'youorderisend') {
        //你点我送产品详情
        window.location.href = whyConfig.baseShopPath + '/peisong/detail.html?id=' + infoId;
    } else if (contentCode == 'zhiyuanzhexiangmu') {
        //志愿项目详情
        window.location.href = whyConfig.baseShopPath + '/volunteerProject/detail.html?id=' + infoId;
    } else if (contentCode == 'wencaihuicanzhanshang') {
        //文采会参展商详情
        window.location.href = whyConfig.baseShopPath + '/organization/merchantDetail.html?id=' + infoId;
    } else if (contentCode == 'wencaihuichanpin') {
        //文采会产品详情
        window.location.href = whyConfig.baseShopPath + '/richMeet/productDetail.html?id=' + infoId;
    } else if (contentCode == 'wenhuapeixun_saas') {
        if (whyConfig.vueRedirect) {
            location.href = `${whyConfig.vueUrl}/${whyConfig.shopPath}/cloud-train/train-detail?trainId=${infoId}`;
        } else {
            window.location.href = whyConfig.baseShopPath + '/cloudTrain/cloudDetail.html?trainId=' + infoId;
        }
    } else if (contentCode == 'wenhuapeixun_shizi_saas') {
        window.location.href = whyConfig.baseShopPath + '/cloudTrain/teacherDetail.html?teacherId=' + infoId;
    } else if (contentCode == 'trainres') { // 培训资源
        window.location.href = whyConfig.baseShopPath + '/repository/detail.html?id=' + infoId;
    } else if (contentCode == 'cms_micro_specialty') { // 微专业
        window.location.href = whyConfig.baseShopPath + '/micro-specialty/detail.html?id=' + infoId;
    }

}




//contentCode 的跳转列表
function toCodeListLink(contentCode, tit, moduleId, data) {
    var url = '';

    if (contentCode == 'zhuantihuodong') {
        //专题活动
        // window.location.href = whyConfig.whyUrl + '/template/activityTopicDetail.do';
    } else if (contentCode == 'huodong') {
        //精彩活动
        window.location.href = '/' + whyConfig.shopPath + '/activity/actlist.html?type=1';
        sessionStorage.setItem('/' + whyConfig.shopPath + '/activity/actlist.html?type=1', tit);

    } else if (contentCode == 'wenchuang') {
        //文创
        window.location.href = '/' + whyConfig.shopPath + '/commodity/list.html';
        sessionStorage.setItem('/' + whyConfig.shopPath + '/commodity/list.html', tit);

    } else if (contentCode == 'lishihuodong') {
        //历史活动
        window.location.href = '/' + whyConfig.shopPath + '/activity/actlist.html?type=2';
        sessionStorage.setItem('/' + whyConfig.shopPath + '/activity/actlist.html?type=2', tit);

    } else if (contentCode == 'changguan') {
        //热门空间 & 场馆
        window.location.href = '/' + whyConfig.shopPath + '/venue/venuelist.html';
        sessionStorage.setItem('/' + whyConfig.shopPath + '/venue/venuelist.html', tit);

    } else if (contentCode == 'peixun') {
        //热门空间 & 场馆
        window.location.href = '/' + whyConfig.shopPath + '/train/list.html';
        sessionStorage.setItem('/' + whyConfig.shopPath + '/train/list.html', tit);

    } else if (contentCode == 'zhibo' || contentCode == 'zhibo_given') {
        //文化直播 【G】
        window.location.href = '/' + whyConfig.shopPath + '/video/list.html';

    } else if (contentCode == 'huodongshi') {
        //活动室
        window.location.href = '/' + whyConfig.shopPath + '/room/roomlist.html';
        sessionStorage.setItem('/' + whyConfig.shopPath + '/room/roomlist.html', tit);
    } else if (contentCode == 'zhishiwenda') {
        //知识问答
        // http://emehenan.ctwenhuayun.cn/jiaozuo/wechatFunction/contestQuiz.do?topicId=48904538d5ab431494a4c5b3d9fbbe28
    } else if (contentCode == 'yishujianshang') {
        //艺术鉴赏
        window.location.href = '/' + whyConfig.shopPath + '/antique/antiquelist.html';
        sessionStorage.setItem('/' + whyConfig.shopPath + '/antique/antiquelist.html', tit);
    } else if (contentCode == 'wenhuashetuan') {
        //文化社团
        window.location.href = '/' + whyConfig.shopPath + '/assn/assnlist.html';
        sessionStorage.setItem('/' + whyConfig.shopPath + '/assn/assnlist.html', tit);
    } else if (contentCode == 'xianshangtoupiao') {
        //线上投票
        // http://emehenan.ctwenhuayun.cn/jiaozuo/wechatFunction/voteIndex.do?voteId=60bfdb34549f453aa2206de7f6595d93
    } else if (contentCode == 'zhiyuanzhe') {
        //文化志愿者
        window.location.href = '/' + whyConfig.shopPath + '/volunteer/list.html';
        sessionStorage.setItem('/' + whyConfig.shopPath + '/volunteer/list.html', tit);
    } else if (contentCode == 'zhiyuanzhe_qingdao') {
        //志愿者（青岛）
        window.location.href = '/' + whyConfig.shopPath + '/volunteer/list.html';
        sessionStorage.setItem('/' + whyConfig.shopPath + '/volunteer/list.html', tit);
    } else if (contentCode == 'wenhuarili') {
        //文化日历
        window.location.href = '/' + whyConfig.shopPath + '/calendar/list.html';
        sessionStorage.setItem('/' + whyConfig.shopPath + '/calendar/list.html', tit);
    } else if (contentCode == 'xianshangzhanlan') {
        //线上展览
        // http://emehenan.ctwenhuayun.cn/jiaozuo/wechatFunction/cityIndex.do?cityMouldId=f4d0d21d976e4fb2954166aca055ce13&userId=bbfa9a9f4af24f30bd176cee843e0455
    } else if (contentCode == 'dianzizazhi') {
        //电子杂志(青岛)
        window.location.href = '/' + whyConfig.shopPath + '/ebook/list.html';
    } else if (contentCode == 'tongji') {
        //统计
    } else if (contentCode == 'peisong_shenyang') {
        //配送（沈阳）
        window.location.href = '/' + whyConfig.shopPath + '/peisong/index.html';
    } else if (contentCode == 'peixun_liaoning') {
        //线下培训（辽宁）
        window.location.href = '/' + whyConfig.shopPath + '/mooc/trainList.html';
    } else if (contentCode == 'shuziyuedu') {
        //数字阅读
        window.location.href = '/' + whyConfig.shopPath + '/read/list.html';
    } else if (contentCode == 'muke_shenzhen') {
        //文化慕课（深圳）
        window.location.href = '/' + whyConfig.shopPath + '/szmk/index.html';
    } else if (contentCode == 'feiyi_hunan') {
        //非遗名录（湖南）
        window.location.href = '/' + whyConfig.shopPath + '/heritage/source.html';
    } else if (contentCode == 'wenjuandiaocha') {
        //问卷调查
        window.location.href = '/' + whyConfig.shopPath + '/survey/list.html';
    } else if (contentCode == 'zx_information') {
        window.location.href = '/' + whyConfig.shopPath + '/infolist/infolist.html?informationModuleId=' + data.areaContentTypeSub;
        sessionStorage.setItem('/' + whyConfig.shopPath + '/infolist/infolist.html?informationModuleId=' + data.areaContentTypeSub, tit);
    } else if (contentCode.startsWith('zx_zxcode')) {
        window.location.href = '/' + whyConfig.shopPath + '/infolist/infolist.html?informationModuleId=' + moduleId;
        sessionStorage.setItem('/' + whyConfig.shopPath + '/infolist/infolist.html?informationModuleId=' + moduleId, tit);
    } else if (contentCode.split('_')[0] == 'zx') {
        //文化资讯 【G】 & 非遗传承 【G】
        window.location.href = '/' + whyConfig.shopPath + '/infolist/infolist.html?informationModuleId=' + contentCode.split('_')[1];
        sessionStorage.setItem('/' + whyConfig.shopPath + '/infolist/infolist.html?informationModuleId=' + contentCode.split('_')[1], tit);

    } else if (contentCode == 'zhiyuan_hunan') {
        //志愿者活动 
        window.location.href = '/' + whyConfig.shopPath + '/voluntaryService/index.html?code=4';
    } else if (contentCode == 'peisongzhiyuanzhetuandui') {
        //配送志愿者团队 
        window.location.href = '/' + whyConfig.shopPath + '/voluntaryService/index.html?code=5';
    } else if (contentCode == 'youorderisend') {
        //你点我送-产品列表
        window.location.href = '/' + whyConfig.shopPath + '/peisong/list.html';
    } else if (contentCode == 'zhiyuanzhexiangmu') {
        //志愿项目 
        window.location.href = '/' + whyConfig.shopPath + '/volunteerProject/list.html';
    } else if (contentCode == 'wencaihuicanzhanshang') {
        //文采会参展商列表
        window.location.href = whyConfig.baseShopPath + '/organization/index.html';
    } else if (contentCode == 'wencaihuichanpin') {
        //文采会产品列表
        window.location.href = whyConfig.baseShopPath + '/richMeet/productList.html';
    } else if (contentCode == 'wenhuapeixun_saas') {
        window.location.href = whyConfig.baseShopPath + '/cloudTrain/list.html?trainSchoolId=' + data.areaContentTypeSub;
    } else if (contentCode == 'wenhuapeixun_shizi_saas') {
        window.location.href = whyConfig.baseShopPath + '/teacherDatabase/list.html?schollId=' + data.areaContentTypeSub;
    }

}

//跳转到文化云首页
function toWhyIndex() {
    if (/wenhuayun/.test(ua)) { //APP端
        if (window.injs) { //判断是否存在方法
            injs.accessAppPage(14, 0);
        }
    } else { //H5
        // 深圳第三方
        let userAgent = getUrlParam('userAgent');
        if (userAgent && userAgent == 'isSZSMT') {
            window.parent.postMessage('handleHomePage', "*")
        } else {
            window.parent.location.href = whyConfig.baseShopPath + "/index.html";
        }
    }
}

//图片列表排版
function imgStyleFormat(className1, className2) {
    if (className2) { //图片列表排版
        var plist = $("." + className1 + ">ul>li");
        for (var i = 0; i < plist.length; i++) {
            var num = plist.eq(i).find("." + className2 + ">ul>li");
            num.css("float", "left");
            if (num.length == 1) {
                num.css("width", "540px")
                num.find("img").css("width", "520px")
                num.find("img").css("margin", "10px")
            } else if (num.length > 1 && num.length < 5) {
                num.css("width", "280")
                num.css("height", "280")
                num.find("img").css("width", "260px")
                num.find("img").css("margin", "10px")
            } else {
                num.css("width", "170")
                num.css("height", "170")
                num.find("img").css("width", "150px")
                num.find("img").css("margin", "10px")
            }
        }
    } else { //图片排版（非列表）
        var num = $("." + className1 + ">ul>li");
        num.css({
            "float": "left",
            "position": "relative",
            "margin": "5px"
        });
        if (num.length == 1) {
            num.css("width", "550px")
            num.css("height", "550px")
            num.find("img").css({
                "max-height": "550px",
                "max-width": "550px",
                "margin": "auto",
                "position": "absolute",
                "left": "0",
                "right": "0",
                "top": "0",
                "bottom": "0"
            })
        } else if (num.length > 1 && num.length < 5) {
            num.css("width", "270")
            num.css("height", "270")
            num.find("img").css({
                "max-height": "270px",
                "max-width": "270px",
                "margin": "auto",
                "position": "absolute",
                "left": "0",
                "right": "0",
                "top": "0",
                "bottom": "0"
            })
        } else {
            num.css("width", "176")
            num.css("height", "176")
            num.find("img").css({
                "max-height": "176px",
                "max-width": "176px",
                "margin": "auto",
                "position": "absolute",
                "left": "0",
                "right": "0",
                "top": "0",
                "bottom": "0"
            })
        }
    }
}

(function () {

    var phoneWidth = parseInt(window.screen.width);
    var phoneScale = phoneWidth / 750;
    var ua = navigator.userAgent; //浏览器类型
    if (/Android (\d+\.\d+)/.test(ua)) { //判断是否是安卓系统
        var version = parseFloat(RegExp.$1); //安卓系统的版本号
        if (version > 2.3) {
            document.write('<meta name="viewport" content="width=750, minimum-scale = ' + phoneScale + ', maximum-scale = ' + phoneScale + ', target-densitydpi=device-dpi">');
        } else {
            document.write('<meta name="viewport" content="width=750, target-densitydpi=device-dpi">');
        }
    } else {
        document.write('<meta name="viewport" content="width=750, user-scalable=no, target-densitydpi=device-dpi">');
    }


    /*
    //SEO
    if(whyConfig.shopPath == 'xz' && window.location.host != 'nodeeme.wenhuayun.cn') {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if(curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    }*/


}());

//图片撑满居中
(function (a) {
    var b = {
        "boxWidth": 0,
        "boxHeight": 0,
        "path": "src"
    };
    a.fn.extend({
        "picFullCentered": function (c) {
            var d = a.extend({}, b, c);
            this.each(function () {
                if (d.boxWidth && d.boxHeight) {
                    var g = a(this);
                    var f = d.boxWidth / d.boxHeight;
                    var e = new Image();
                    e.onload = function () {
                        var i = e.width;
                        var h = e.height;
                        if (i / h >= f) {
                            var l = (d.boxHeight * i) / h;
                            var k = (l - d.boxWidth) / 2 * (-1);
                            g.css({
                                "width": "auto",
                                "height": "100%",
                                "position": "absolute",
                                "top": "0",
                                "left": k
                            });
                        } else {
                            var j = (d.boxWidth * h) / i;
                            var m = (j - d.boxHeight) / 2 * (-1);
                            g.css({
                                "width": "100%",
                                "height": "auto",
                                "position": "absolute",
                                "top": m,
                                "left": "0"
                            });
                        }
                    };
                    e.src = g.attr(d.path);
                }
            });
            return this;
        }
    });
})(jQuery);

//
// (function(open) {
//     XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
//         this.addEventListener("readystatechange", function() {
//             if (this.readyState == 4) {
//                 //console.log(this.responseText)
//                 if (this.responseText == '{"err":40}') {
//                     window.location.href = window.location.href;
//                 }
//             }
//         }, false);
//         open.call(this, method, url, async, user, pass);
//     };
// })(XMLHttpRequest.prototype.open);


//设置H5title或APPtitle
if (!(window.location.href.includes('index_common.html') || window.location.href.includes('index.html'))) {
    // setTitle();
}
getTit();
//app获取用户Id
getAppUserId();

// 区域排序m
function rankArea(areaData) {
    $(".main").append('<div id="area_A"></div>');
    for (var i = 0; i < areaData.length; i++) {
        if (areaData[i].areaCode !== 'area_T' && areaData[i].areaCode !== 'area_A') {
            $(".main").append('<div id="' + areaData[i].areaCode + '"></div>');
        }
    }
    $(".main").append('<div id="area_T"></div>');
}

// 区域排序yj
function rankAreaYj(areaData) {
    $(".main").append('<div id="area_yj_F"></div>');
    for (var i = 0; i < areaData.length; i++) {
        if (areaData[i].areaCode !== 'area_yj_F') {
            $(".main").append('<div id="' + areaData[i].areaCode + '"></div>');
        }
    }
}

function toAuto() {
    let url = `/${whyConfig.shopPath}/activityoverlay/certification.html?callback=${encodeURIComponent(window.location.href)}`
    window.location = url
}

//跳转到设置
function preUserSetting() {
    // console.log('userId',userId)
    if (userId == null || userId == '') {
        publicLogin(location.href);
        return;
    }
    window.location = '/' + whyConfig.shopPath + '/user/setting.html';
    // var url = util.encodeUrl(location.href)
    // url = location.origin + '/' + whyConfig.shopPath + '/removeSession.html?url=' + url;
    // url = util.encodeUrl(url);

    // window.location = whyConfig.whyUrl + "/wechatUser/preUserSetting.do" + "?shopPath=" + whyConfig.shopPath + '&callback=' + url;
}

// 防抖
function debounce(fn, wait) {
    var timeout = null;
    return function () {
        if (timeout !== null) clearTimeout(timeout);
        timeout = setTimeout(fn, wait);
    }
}

// 节流
var throttle = function (func, delay) {
    var prev = Date.now();
    return function () {
        var context = this;
        var args = arguments;
        var now = Date.now();
        if (now - prev >= delay) {
            func.apply(context, args);
            prev = Date.now();
        }
    }
}

// 添加浏览量
function addPvCount(areaId, infoId) {
    if (util.qs('sectionId') || whyConfig.sectionId) {
        var proxy = '/' + whyConfig.shopPath + '/store';
        var query = {
            _url: 'apiSpecialSection/addPvCount.do',
            shopPath: whyConfig.shopPath,
            sectionId: util.qs('sectionId') || whyConfig.sectionId,
            areaId: areaId,
            infoId: infoId
        }
        $.post(proxy, query, (res) => { })
    }
}
// 添加音视频播放量
function addPlayCount(areaId, infoId) {
    if (util.qs('sectionId') || whyConfig.sectionId) {
        var proxy = '/' + whyConfig.shopPath + '/store';
        var query = {
            _url: 'apiSpecialSection/addPlayCount.do',
            shopPath: whyConfig.shopPath,
            sectionId: util.qs('sectionId') || whyConfig.sectionId,
            areaId: areaId,
            infoId: infoId
        }
        $.post(proxy, query, (res) => {
            return
        })
    }
}

// 装配通用板式增加播放量记录
function newAddPlayCount(infoId) {
    var query = {
        startTime: '',
        endTime: '',
        stayTime: 0,
        flag: 1,
        userId: '',
        liveActivityId: infoId,
        recordId: '',
        _url: whyConfig.gateway + '/why/liveWatchRecord/create',
    }
    $.post(proxy, query, (res) => {
        return
    })
}
// 添加添加点赞量
function addZanCount(areaId, infoId) {
    if (util.qs('sectionId') || whyConfig.sectionId) {
        var proxy = '/' + whyConfig.shopPath + '/store';
        var query = {
            _url: 'apiSpecialSection/addZanCount.do',
            shopPath: whyConfig.shopPath,
            sectionId: util.qs('sectionId') || whyConfig.sectionId,
            areaId: areaId,
            infoId: infoId
        }
        $.post(proxy, query, (res) => {
            if (res.data.status == 200) {
                return dialogAlert('提示', '点赞成功！');
            }
        })
    }
}

//广告位统计
function addAdvertStatistics(code, userId, lon, lat, url) {
    var time = parseInt(new Date().getTime() / 1000)
    var proxy = '/' + whyConfig.shopPath + '/proxy';
    var query = {
        _url: whyConfig.gateway + '/why/advert/addAdvertStatistics',
        shopPath: whyConfig.shopPath,
        shopProvince: whyConfig.shopProvince,
        positionCode: code + '_100' || '',
        from: 'h5',
        host: window.location.host || '',
        url: url || '',
        time: time,
        agent: ua || '',
        referer: document.referrer || '',
        userId: userId || '',
        deviceId: '',
        longitude: lon || '',
        latitude: lat || '',
    }

    return new Promise(function (resolve, reject) {
        $.post(proxy, query, (res) => {
            return resolve(res)
        })
    })
}

function isForbidCopyOrPaste(url, condition) {
    var gateway_url = '/' + whyConfig.shopPath + '/gateway';
    condition._url = url;
    return new Promise(function (resolve, reject) {
        $.ajax({
            url: gateway_url,
            type: 'POST',
            dataType: 'json',
            contentType: "application/json",
            data: JSON.stringify(condition),
            success: function (res) {
                if (res.err === 0) {
                    return resolve(res.data)
                } else {
                    return reject(res.err)
                }
            },
            error: function (err) {
                return reject(err)
            }
        })
    })
}
// 获取阿里上传参数
function getAliOsssign() {
    // 可以判断当前expire是否超过了当前时间， 如果超过了当前时间， 就重新取一下，3s 作为缓冲。
    let now = timestamp = Date.parse(new Date()) / 1000;
    // if (expire < now + 3) {
    // let query = {
    //     _url: '/why/aliOss/getSign',
    // }
    // var gateway = '/' + whyConfig.shopPath + '/gateway';
    $.post(whyConfig.gateway + '/why/aliOss/getSign', {}, function (res) {
        let data = res || {};
        accessid = data.accessid;
        host = data.host;
        policy = data.policy;
        signature = data.signature;
    }, "json");
    // }
}
// 第三方链接跳转
function getThirdLink(condition) {
    // "relatedId": util.qs('id'), 详情id
    // "type": 2 // 类型 1：场馆，2：活动，26: 线下培训 35：文化慕课
    var gateway_url = whyConfig.gateway + '/why/commonExternalLink/queryList';
    condition._url = '/why/commonExternalLink/queryList';
    return new Promise(function (resolve, reject) {
        $.ajax({
            url: gateway_url,
            type: 'POST',
            dataType: 'json',
            contentType: "application/json",
            data: JSON.stringify(condition),
            success: function (res) {
                if (res.status == 200) {
                    return resolve(res)
                } else {
                    return reject(res.errMsg)
                }
            },
            error: function (err) {
                return reject(err)
            }
        })
    })
}

function getInfomationModule() {
    let condition = {
        informationModuleId: util.qs('cid'),
        shopPath: whyConfig.shopPath,
        _url: 'apiInformation/getInformationModule.do'
    }
    let gateway_url = '/' + whyConfig.shopPath + '/web' + '/proxy';
    return new Promise(function (resolve, reject) {
        $.ajax({
            url: gateway_url,
            type: 'POST',
            dataType: 'json',
            contentType: "application/json",
            data: JSON.stringify(condition),
            success: function (res) {
                if (res.err === 0) {
                    return resolve(res.data)
                } else {
                    return reject(res.err)
                }
            },
            error: function (err) {
                return reject(err)
            }
        })
    })
}

// 加密方法
function codeEncrypt(Text) {
    if (!Text) return;
    const KEY = CryptoJS.enc.Utf8.parse("d7f6822a8a52a4c4");
    const IV = CryptoJS.enc.Utf8.parse("076ce634d7da11eb");
    const source = CryptoJS.enc.Utf8.parse(Text);
    const encrypted = CryptoJS.AES.encrypt(source, KEY, {
        iv: IV,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7,
    });
    return encrypted.toString();
}

//解密方法
function decodeAesString(str) {
    let KEY = 'd7f6822a8a52a4c4';
    let IV = '076ce634d7da11eb';
    if (KEY.length < 16) throw Error('the key length can\'t less than 16');
    KEY = KEY.slice(-16);
    KEY = CryptoJS.enc.Utf8.parse(KEY);
    IV = IV.slice(-16);
    IV = CryptoJS.enc.Utf8.parse(IV);
    var HEXOBJ = CryptoJS.enc.Utf8.parse(str);
    var base64Str = CryptoJS.enc.Base64.stringify(HEXOBJ);
    base64Str = CryptoJS.enc.Base64.parse(base64Str).toString(CryptoJS.enc.Utf8);
    return JSON.parse(CryptoJS.AES.decrypt(base64Str, KEY, {
        iv: IV
    }).toString(CryptoJS.enc.Utf8));
}

//滚动条在Y轴上的滚动距离
function getScrollTop(dom) {
    if (dom) return dom.scrollTop;
    var scrollTop = 0,
        bodyScrollTop = 0,
        documentScrollTop = 0;
    if (document.body) {
        bodyScrollTop = document.body.scrollTop;
    }
    if (document.documentElement) {
        documentScrollTop = document.documentElement.scrollTop;
    }
    scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
    return scrollTop;
}

//文档的总高度
function getScrollHeight(dom) {
    if (dom) return dom.scrollHeight;
    var scrollHeight = 0,
        bodyScrollHeight = 0,
        documentScrollHeight = 0;
    if (document.body) {
        bodyScrollHeight = document.body.scrollHeight;
    }
    if (document.documentElement) {
        documentScrollHeight = document.documentElement.scrollHeight;
    }
    scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
    return scrollHeight;
}

//浏览器视口的高度
function getWindowHeight(dom) {
    if (dom) return dom.offsetHeight;
    var windowHeight = 0;
    if (document.compatMode == "CSS1Compat") {
        windowHeight = document.documentElement.clientHeight;
    } else {
        windowHeight = document.body.clientHeight;
    }
    return windowHeight;
}

//下拉加载
function lazyLoad(self, dom) {
    if (self.sectionData.areaDataDefaultNumState == 2) {
        var target = dom || window;
        target.addEventListener('scroll', debounce(() => {
            if (self.isEnd) return;
            if (getScrollTop(dom) + getWindowHeight(dom) + 20 >= getScrollHeight(dom)) {
                self.page++
                self.sectionData.areaDataDefaultNum = self.page * self.limit;
                if (self.sectionData.areaDataDefaultNum >= self.sectionData.areaDetailList.length) self.isEnd = true;
            }
        }, 200))
    }
}
// ne 水印位置右上
function waterMark(sectionData, imgUrl, imgWidth, imgHeight, position = 'ne',) {
    if (sectionData.pageIsWatermark && sectionData.pageWatermarkImg) {
        if (imgUrl.indexOf('aliyuncs.com') != -1) {
            imgHeight == 0 ?
                imgUrl = imgUrl + `?x-oss-process=image/resize,m_fixed,w_${imgWidth},limit_0` :
                imgUrl = imgUrl + `?x-oss-process=image/resize,m_fixed,w_${imgWidth},h_${imgHeight},limit_0`;
            //提取图片路径
            // waterMarkUrl =  waterMarkUrl.replace(/^(.*\.com\/)/,'');
            // if(waterMarkUrl.indexOf('?x-oss-process=image') != -1){
            //     waterMarkUrl = waterMarkUrl.replace(/\?.*/g,'');
            // }
            // waterMarkUrl = sectionData.pageWatermarkImg + '?x-oss-process=image/resize,w_80,h_80';
            // var code = Base64.encode(waterMarkUrl);
            // code = code.replace(/\+/g,'-');
            // code = code.replace(/\//g,'_');
            // code = code.replace(/=/g,'');
            return imgUrl + `,image/watermark,image_${sectionData.pageWatermarkImg},g_${position},x_10,y_10`;
        } else {
            return imgUrl;
        }
    }
    return imgUrl;
}

function getTrainStatus(type) {
    let _actData = '';
    let _moocData = '';
    let _roomData = '';
    if (type == 2) {
        _actData = JSON.parse(sessionStorage.getItem('h5_switchPrice_activity'));
    } else if (type == 26) {
        _moocData = JSON.parse(sessionStorage.getItem('h5_switchPrice_mooc'));
    } else if (type == 30) {
        _roomData = JSON.parse(sessionStorage.getItem('h5_switchPrice_room'));
    }

    let condition = {
        shopPath: whyConfig.shopPath,
        shopProvince: whyConfig.shopProvince,
        configType: type // 线下培训-26 活动 -2  活动室 - 30
    }
    var gateway_url = '/' + whyConfig.shopPath + '/gateway';
    condition._url = '/why/page/config/find';
    return new Promise(function (resolve, reject) {
        if (_actData) {
            return resolve(_actData)
        } else if (_moocData) {
            return resolve(_moocData)
        } else if (_roomData) {
            return resolve(_roomData)
        } else {
            $.ajax({
                url: gateway_url,
                type: 'POST',
                dataType: 'json',
                contentType: "application/json",
                data: JSON.stringify(condition),
                success: function (res) {
                    if (res.err === 0) {
                        if (type == 2) {
                            sessionStorage.setItem('h5_switchPrice_activity', JSON.stringify(res.data));
                        } else if (type == 26) {
                            sessionStorage.setItem('h5_switchPrice_mooc', JSON.stringify(res.data));
                        } else if (type == 30) {
                            sessionStorage.setItem('h5_switchPrice_room', JSON.stringify(res.data));
                        }
                        return resolve(res.data)
                    } else {
                        return reject(res.err)
                    }
                },
                error: function (err) {
                    return reject(err)
                }
            })
        }
    })
}